<?php
include("hotel_class.php");

/*Json PHP interpreter for Expedia HotelList*/
	class Json 
	{
		private $jsonResponse="";

	public	function Json($resp)
	{
		$this->jsonResponse=$resp;
		//print_r ($resp);
	}
	
	function GetJsonRawData()
	{
		if(isset($this->jsonResponse))
			print_r ($this->jsonResponse);
	}

	public function SetJsonResponse($response)
	{
		$this->jsonResponse=$response;		
		//print_r($response);
	}
	
	function GetCustomerSesionId()
	{
		echo "TIP: ".gettype($this->jsonResponse);
		return $this->jsonResponse->{"HotelListResponse"};
	}
	
	function GetNumberOfRoomsRequested()
	{
		return $this->jsonResponse->{"HotelListResponse"}->{"numberOfRoomsRequested"};
	}
	
	function GetMoreResultsAvailable()
	{
		return $this->jsonResponse->{"HotelListResponse"}->{"moreResulstsAvailable"};
	}
	
	function GetCacheKey()
	{
		return $this->jsonResponse->{"HotelListResponse"}->{"cacheKey"};
	}
	
	function GetCacheLocation()
	{
		return $this->jasonResponse->{"HotelListResponse"}->{"cacheLocation"};
	}
		
	function GetHotelList()
	{	
            $size=$this->jsonResponse->{"HotelListResponse"}->{"HotelList"}->{"@size"};
            for($i=0;$i<$size;$i++)
            {
                    $hotelList[$i]=new Hotel($this->jsonResponse->{"HotelListResponse"}->{"HotelList"}->{"HotelSummary"}[$i]);
                    //$hotelData=$this->jsonResponse->{"HotelListResponse"}->{"HotelList"}->{"HotelSummary"}[$i];
                    //print_r("Number of hotel: ".$i." ".$hotelList[$i]->GetAddressOne() );
            }
            return $hotelList;
	}
    }
	
?>